package com.leyou.auth.web;

import com.leyou.auth.service.ClientAuthService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/client")
public class ClientAuthController {

    private final ClientAuthService clientAuthService;

    public ClientAuthController(ClientAuthService clientAuthService){
        this.clientAuthService = clientAuthService;
    }

    /**
     * 验证服务等信息，返回加密key
     * @param clientId
     * @param secret
     * @return
     */
    @GetMapping("/key")
    public ResponseEntity<String> getAuthKey(
            @RequestParam("clientId")String clientId,
            @RequestParam("secret")String secret){

        return ResponseEntity.ok(this.clientAuthService.getAuthKey(clientId,secret));
    }
}
